package org.github.socket.protocol.ykq.client;

import org.github.socket.protocol.ykq.client.process.ClientProcessStrategyDispatcherProcessor;
import org.github.socket.protocol.ykq.protocol.YunKProtocol;
import org.smartboot.socket.transport.AioQuickClient;
import org.smartboot.socket.transport.AioSession;
import org.tinylog.Logger;

import java.io.IOException;
import java.nio.channels.CompletionHandler;

public class YunKClient {
    public static void main(String[] args) throws IOException {
        AioQuickClient client = new AioQuickClient("127.0.0.1", 9530, new YunKProtocol(), new ClientProcessStrategyDispatcherProcessor());
        client.start(null, new CompletionHandler<AioSession, Object>() {
            @Override
            public void completed(AioSession result, Object attachment) {
                Logger.info("start success");
                client.shutdown();
            }

            @Override
            public void failed(Throwable exc, Object attachment) {
                Logger.error("start fail");
                exc.printStackTrace();
            }
        });
    }
}